var app = getApp();
Component({
    properties: {
        pdv: Number,
        slidedata: Array,
        cover: String,
        fendian: Object,
        shop: Object
    },
    ready() {
        if (this.data.slidedata.length > 0) {

            clearTimeout(this.data.timer);
            this.setData({
                'state.slidedata': this.data.slidedata
            });
            this.slideAnimate();
        }
    },
    data: {
        animate: false,
        timer: false,
        state: {
            slidedata: [],
            currentIndex: 0,
            currentData: {},
            status: "hide",
            anmiate: 0
        },
    },
    options: {
        addGlobalClass: true,
    },

    methods: {
        callphone(e) {
            app.com.callphone(e);
        },
        gomore(e){
            var myEventDetail = {
                type: 'more'
            }
            var myEventOption = {}
            this.triggerEvent('parentEvent', myEventDetail, myEventOption)
        },
        location: function (e) {
            app.com.location(e);
        },
        handleClick: function (e) {
            var myEventDetail = {
                type: e.currentTarget.dataset.type
            }
            var myEventOption = {}
            this.triggerEvent('parentEvent', myEventDetail, myEventOption)
        },
        slideAnimate() {
            var self = this;
            setTimeout(function () {
                t();
            }, 1000);
            var t = function () {
                var slidedata = self.data.state.slidedata;
                var e = JSON.parse(JSON.stringify(slidedata[0]));
                slidedata.push(e);
                self.setData({
                    slidedata: slidedata,
                    animate: true
                }, function () {
                    self.data.timer = setTimeout(function () {
                        clearTimeout(self.data.timer);
                        self.data.state.slidedata.splice(0, 1);
                        self.setData({
                            animate: false,
                            slidedata: self.data.state.slidedata
                        }, function () {
                            self.slideAnimate();
                        });
                    }, 600);
                });
            };
        },

    }

})